home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MssgSI.cpp
-
- Contains: Implementation of Mac specific DefaultAccessorSI class.
-
- Owned by: Nick Pilch
-
- Copyright: © 1994 - 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <38> 10/4/95 jpa Added missing ODVolatiles [1285799]
- <37> 25/09/95 NP 1979071: Check results of operator new.
- <36> 9/11/95 NP 1272294: Messaging code cleanup. 1283174:
- Mem leak plugs.
- <35> 9/8/95 jpa eeh: 1269501: Lowercase before string
- comparisons.
- <34> 8/23/95 NP 1276287: Move constant kODAppShell.
- <33> 8/18/95 NP 1274946: Add kODErrCantCountFromLists.
- <32> 8/16/95 eeh 1277001: remove ContainerRepresentsPart
- <31> 8/7/95 NP 1275104: Exception safety.
- <30> 8/3/95 RR #1257260: Collapse B classes. Remove
- somInit methods. Don't call IsInitialized
- or SubclassResponsibility
- <29> 8/1/95 eeh 1265319: accept NULL as representing part
- <28> 7/27/95 eeh 1204615: call TrySwapToRootPart for 'exmn'
- <27> 7/21/95 eeh 1266906: fix CallCountProc; 1262143: call
- ODDisposeAppleEvent
- <26> 6/30/95 JP Release on dispose of standard part token
- <25> 6/28/95 eeh 1262143: dispose AEDescs
- <24> 6/27/95 NP 1263224: Remove Release call in
- DiposeTokenProc for now.
- <23> 6/26/95 NP 1262143: Dispose copy of Apple event made
- in CallEventHandler
- <22> 6/22/95 NP 1261984: Don't delete token after passing
- it to ODNameResolver::DisposeToken!
- <21> 6/20/95 NP Removed dangerous comment.
- <20> 6/19/95 eeh 1246443: add PartFrameFromStandardPartToken
- etc.
- <19> 6/13/95 eeh 1257105: fix string compare
- <18> 6/7/95 eeh 1250399: implement default CompareProc
- <17> 5/21/95 NP 1248898: GetUserToken, ODDescToAEDesc, etc.
- recipe change.
- <16> 5/18/95 eeh 1250061: implement countproc
- <15> 4/28/95 eeh 1244258: IsValid->CheckValid; SOM_TRY
- around it
- <14> 4/27/95 NP 1244309-Default count proc returns -1 only
- if the part is equal to kODAppShell.
- <13> 4/27/95 eeh 1240648: call somSelf->IsValid
- <12> 4/25/95 NP 1186795, 1237220, 1240571: Fixed whose
- clauses by allowing swapping in count proc.
- <11> 4/14/95 NP 1239651: Include SEPriv.h. 1238022: default
- event handler was almost always returning
- noErr.
- <10> 4/7/95 eeh 1236842: call TrySwapToRootPart
- <9> 3/24/95 eeh 1232249: remove frame from
- DEFAULT_ACCESSOR_PARAMS
- <8> 3/21/95 JP 1192027: Include ODRgstry & change some
- constant names
- <7> 3/13/95 NP 1226003: Remove GetContainingFrame from the
- API. Use GetContextFromToken.
- <6> 3/2/95 eeh 1214783: cleanup related to lists
- <5> 2/22/95 eeh 1222901: look for StandardPartToken
- <4> 2/21/95 eeh 1214783: add WildcardFromList accessor;
- change accessor API
- <3> 2/3/95 eeh 1217393: use new ODDesc etc
- <2> 1/27/95 NP 1213948: New classes for ODDesc et al.
- <1> 1/25/95 eeh #1214783-first check-in as unique file.
- <3> 1/11/95 NP #1188520-Pass real ODPart to parts.
- <2> 1/9/95 NP 1194880: MssgSI name changes.
- <1> 11/15/94 NP first checked in
- <7> 9/23/94 NP 1188520-Pass the real ODPart descendent to
- the SemanticInterface extension rather than
- the ODPartWrapper.
- <6> 9/9/94 NP 1185851: implement scripting. 1184040: API
- changes.
- <5> 9/9/94 jpa Removed call to parent in Release, at
- Nick's request. [1185656]
- <4> 7/8/94 NP Initialize fHelper field.
- <3> 7/8/94 NP Fixed bugs, implemented coercion handlers,
- fixed initialization.
- <2> 7/5/94 NP Filled in CallEventHandler.
- <1> 7/1/94 NP first checked in
-
- To Do:
- In Progress:
- */
-
-
- #ifndef _EXCEPT_
- #include "Except.h"
- #endif
-
- #ifndef _SEPRIV_
- #include "SEPriv.h"
- #endif
-
- #ifndef _DFLTACS_
- #include <DfltAcs.h>
- #endif
-
- #ifndef _ODDESUTL_
- #include <ODDesUtl.h>
- #endif
-
- #ifndef SOM_ODOSLToken_xh
- #include "ODOSLTkn.xh"
- #endif
-
- #ifndef SOM_ODAppleEvent_xh
- #include "ODAplEvt.xh"
- #endif
-
- #ifndef _ODREGISTRY_
- #include "ODRgstry.xh"
- #endif
-
- #ifndef _SEUTILS_
- #include <SEUtils.h>
- #endif
-
- #ifndef SOM_ODNameResolver_xh
- #include <NamRslvr.xh>
- #endif
-
- #ifndef _PASCLSTR_
- #include <PasclStr.h>
- #endif
-
- #define VARIABLE_MACROS
- #define DefaultAccessorSI_Class_Source
- #include <MssgSI.xih>
-
- #ifndef SOM_Module_OpenDoc_StdDefs_defined
- #include <StdDefs.xh>
- #endif
-
- #pragma segment DefaultAccessorSI
-
- //------------------------------------------------------------------------------
- // function prototypes
- //------------------------------------------------------------------------------
-
- static void ResolveDesc( Environment *ev, ODPart* part, ODSession* session,
- ODOSLToken* obj, AEDesc* data );
- static short BitwiseCompare( AEDesc* data1, AEDesc* data2 );
- static short CompareDescs( AEDesc* data1, AEDesc* data2 );
- //static ODBoolean ContainerRepresentsPart( Environment* ev,
- // ODNameResolver* resolver, ODOSLToken* container );
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::InitCPlusSemanticInterface
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSIInitCPlusSemanticInterface(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* base,
- SIHelperAbs* helper,
- ODSession* session)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSIInitCPlusSemanticInterface");
-
- SOM_TRY
- somSelf->InitSemanticInterface(ev, base, session);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::somUninit
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSIsomUninit(DefaultAccessorSI *somSelf)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSIsomUninit");
-
- DefaultAccessorSI_parents_somUninit(somSelf);
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::InitSemanticInterface
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSIInitSemanticInterface(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* base,
- ODSession* session)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSIInitSemanticInterface");
-
- _fSession = session;
-
- DefaultAccessorSI_parent_ODSemanticInterface_InitSemanticInterface(somSelf, ev, base, session);
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::GetSIHelper
- //------------------------------------------------------------------------------
-
- SOM_Scope SIHelperAbs* SOMLINK DefaultAccessorSIGetSIHelper(DefaultAccessorSI *somSelf, Environment *ev)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSIGetSIHelper");
-
- return kODNULL; // was _fHelper;
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallEventHandler
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallEventHandler(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODAppleEvent* theODAppleEvent,
- ODAppleEvent* reply)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallEventHandler");
-
- OSErr error; //= errAEEventNotHandled;
-
- SOM_TRY
- somSelf->CheckValid(ev);
-
- AppleEvent realMessage;
-
- THROW_IF_ERROR( ODDescToAEDesc(theODAppleEvent, &realMessage) );
-
- AEEventClass eventClass = (AEEventClass)GetSLongAttr(
- &realMessage, keyEventClassAttr);
- AEEventID eventID = (AEEventID)GetSLongAttr(
- &realMessage, keyEventIDAttr);
-
- EventHandlerProc ehp;
-
- if ( (eventClass == kAECoreSuite) && (eventID == kAEGetData) )
- ehp = HandleGetData;
- else if ( (eventClass == kAECoreSuite) && (eventID == kAESetData) )
- ehp = HandleSetData;
- else
- ehp = kODNULL;
-
- if ( ehp )
- error = (*ehp)( ev, thePart, theODAppleEvent, reply, _fSession );
- else
- error = errAEEventNotHandled;
-
- ODDisposeAppleEvent(&realMessage);
-
- THROW_IF_ERROR( error );
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallCoercionHandler
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallCoercionHandler(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODDesc* theODDesc,
- ODDescType toType,
- ODDesc* result)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallCoercionHandler");
-
- OSErr error = errAECoercionFail;//= CallCoercionHandler(thePart, theODDesc, toType, result);
- SOM_TRY
- somSelf->CheckValid(ev);
- WARN( "DefaultAccessorSICallCoercionHandler not implemented" );
- THROW( error );
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallObjectAccessor
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallObjectAccessor(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODDescType desiredClass,
- ODOSLToken* container,
- ODDescType containerClass,
- ODDescType form,
- ODDesc* selectionData,
- ODOSLToken* value)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallObjectAccessor");
-
- OSErr error;
- SOM_TRY
- somSelf->CheckValid(ev);
-
- ODDesc* userTokenWrapper = kODNULL;
-
- AEDesc realToken = NULL_DESCRIPTOR_DEFINITION;
- DescType containerType = typeNull;
- ODNameResolver* resolver = _fSession->GetNameResolver(ev);
-
- ASSERT(resolver->IsODToken( ev, container ), kODTrue);
- userTokenWrapper = resolver->GetUserToken(ev, container);
- THROW_IF_ERROR(ODDescToAEDesc(userTokenWrapper, &realToken ));
- containerType = realToken.descriptorType;
-
- error = errAEAccessorNotFound;
- PartAccessorProc pac;
-
- if ( (containerType == kODStandardPartTokenType)
- || CanBeStandardPartToken( &realToken ) )
- pac = GetWildcardFromPart;
- else if ( containerType == typeAEList )
- pac = GetWildcardFromList;
- else if ( (desiredClass == cPart) && (containerType == typeNull) )
- pac = GetPartFromNULL;
- else if ( (desiredClass == cProperty) && (containerType == typeNull) )
- pac = GetPropFromNULL;
- else if ( (thePart == kODAppShell) && ((containerType == typeNull)
- || (containerType == typeObjectBeingExamined)) )
- pac = TrySwapToRootPart;
- else
- pac = kODNULL;
-
- if ( pac )
- {
- // We have to pass value as an ODOSLToken* in case the accessor
- // needs to call CreateSwapToken on it.
-
- error = (*pac)( ev, thePart, desiredClass, &realToken,
- containerClass, form, selectionData, value,
- _fSession );
- }
- (void)AEDisposeDesc( &realToken );
- THROW_IF_ERROR( error );
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallPredispatchProc
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallPredispatchProc(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODAppleEvent* theODAppleEvent,
- ODAppleEvent* reply)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallPredispatchProc");
-
- OSErr error = errAEEventNotHandled;//= CallPredispatchProc(thePart, theODAppleEvent, reply);
- SOM_TRY
- somSelf->CheckValid(ev);
- WARN( "DefaultAccessorSICallPredispatchProc not implemented" );
- THROW_IF_ERROR( error );
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallCompareProc
- //------------------------------------------------------------------------------
-
-
- SOM_Scope void SOMLINK DefaultAccessorSICallCompareProc(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODDescType oper,
- ODOSLToken* obj1,
- ODOSLToken* obj2,
- ODBoolean* result)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallCompareProc");
-
- OSErr error = errAEEventNotHandled;
- AEDesc obj1AsData, obj2AsData, tmpDesc;
-
- SOM_TRY
- somSelf->CheckValid(ev);
-
- obj1AsData.dataHandle = obj2AsData.dataHandle = tmpDesc.dataHandle =
- kODNULL;
- ODNameResolver* resolver = _fSession->GetNameResolver(ev);
- ResolveDesc( ev, thePart, _fSession, obj1, &obj1AsData );
- ResolveDesc( ev, thePart, _fSession, obj2, &obj2AsData );
-
- short compResult;
- if ( obj1AsData.descriptorType == obj2AsData.descriptorType )
- {
- compResult = CompareDescs( &obj1AsData, &obj2AsData );
- }
- else if ( !AECoerceDesc( &obj1AsData, obj2AsData.descriptorType,
- &tmpDesc ) )
- {
- compResult = CompareDescs( &tmpDesc, &obj2AsData );
- (void)AEDisposeDesc( &tmpDesc );
- }
- else if ( !AECoerceDesc( &obj2AsData, obj1AsData.descriptorType,
- &tmpDesc ) )
- {
- compResult = CompareDescs( &tmpDesc, &obj1AsData );
- (void)AEDisposeDesc( &tmpDesc );
- }
- (void)AEDisposeDesc( &obj1AsData );
- (void)AEDisposeDesc( &obj2AsData );
- error = noErr;
-
- switch( oper )
- {
- case kAEEquals:
- *result = compResult == 0;
- break;
- case kAEGreaterThan:
- *result = compResult > 0;
- break;
- case kAELessThan:
- *result = compResult < 0;
- break;
- case kAEGreaterThanEquals:
- *result = compResult >= 0;
- break;
- case kAELessThanEquals:
- *result = compResult <= 0;
- break;
- default:
- error = -2; // <eeh> kAEInvalidCompare or something
- }
- THROW_IF_ERROR( error );
- SOM_CATCH_ALL
- (void)AEDisposeDesc( &obj1AsData );
- (void)AEDisposeDesc( &obj2AsData );
- (void)AEDisposeDesc( &tmpDesc );
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallCountProc
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallCountProc(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODDescType desiredType,
- ODDescType containerClass,
- ODOSLToken* container,
- ODSLong* result)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallCountProc");
-
- // ASK TO SWAP TO SEE IF ROOT PART CAN HANDLE THIS. CallCountProc in
- // NamRslvr.cpp WILL SWAP TO THE ROOT PART IF kODCountProcSwapValue IS
- // RETURNED AND THE PART IS THE SHELL. THIS IS NOT THAT GREAT, SEEING AS
- // THE DEFAULT SEMANTIC INTERFACE SHOULD REALLY BE DETERMINING WHAT THE
- // PROPER PART TO SWAP TO IS.
- SOM_TRY
- somSelf->CheckValid(ev);
- ODNameResolver* resolver = _fSession->GetNameResolver(ev);
-
- if ( thePart == kODAppShell)
- *result = kODCountProcSwapValue;
- else if ( resolver->IsODToken( ev, container ) )
- {
- ODError error = noErr;
- ODDesc* tmpToken = resolver->GetUserToken(ev, container);
- switch( tmpToken->GetDescType(ev) )
- {
- case typeAEList:
- error = kODErrCantCountFromLists;
- break;
- case kODStandardPartTokenType:
- // (NULL token is not acceptable here)
- // <eeh> putting NULL back in because this breaks "every part
- // whose" when the root isn't scriptable.
- case typeNull:
- // do the count;
- break;
- default:
- {
- AEDesc token;
- THROW_IF_ERROR( ODDescToAEDesc( tmpToken, &token ) );
- if ( !CanBeStandardPartToken( &token ) )
- error = errAEEventNotHandled;
- (void)AEDisposeDesc( &token );
- }
- }
- if ( error == noErr )
- {
- if ( desiredType != cPart )
- *result = kODCountProcSwapValue;
- else
- *result = CountEmbeddedParts(ev, thePart);
- }
- else
- THROW( error );
- }
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallDisposeTokenProc
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallDisposeTokenProc(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODOSLToken* unneededToken)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallDisposeTokenProc");
-
- SOM_TRY
- somSelf->CheckValid(ev);
-
- ODNameResolver* resolver = _fSession->GetNameResolver(ev);
- if ( resolver->IsODToken( ev, unneededToken ) )
- {
- ODDesc* realTokenODDesc = resolver->GetUserToken( ev, unneededToken );
- AEDesc realToken;
- THROW_IF_ERROR(ODDescToAEDesc(realTokenODDesc, &realToken ));
- DescType containerType = realToken.descriptorType;
-
- if ( containerType == typeAEList )
- {
- long count;
- THROW_IF_ERROR( AECountItems( &realToken, &count ) );
-
- for ( ODUShort index = 1; index <= count ; ++index )
- {
- AEDesc oneToken;
- DescType tokenDescType;
- THROW_IF_ERROR( AEGetNthDesc( &realToken, index, typeWildCard,
- &tokenDescType, &oneToken ) );
- ODOSLToken* subToken = new ODOSLToken();
- THROW_IF_NULL(subToken);
- subToken->InitODOSLToken(ev);
- THROW_IF_ERROR( AEDescToODDesc( &oneToken, subToken ) );
- (void)AEDisposeDesc( &oneToken );
- // <eeh> don't I need to call back into the resolver for this?
- // It could be someone else's token!
- TRY
- resolver->DisposeToken( ev, subToken );
- // somSelf->CallDisposeTokenProc( ev, thePart, subToken );
- CATCH_ALL
- // <eeh> just ignore errors here....I think.
- ENDTRY
- }
- }
- else if ( containerType == cPart ) // a standard part token
- {
- ODPart* part;
- ODFrame* frame;
-
- PartFrameFromStandardPartToken( &realToken, &part, &frame );
- // BOTH THE PART AND FRAME DO NEED TO BE RELEASED HERE.
- ODReleaseObject( ev, part );
- ODReleaseObject( ev, frame );
- // leave error as errAEEventNotHandled so handle disposed
- }
-
- // now dispose the *copy* we've made! This isn't the token
- // itself. Hell, how *could* we dispose it?
- (void)AEDisposeDesc( &realToken );
- }
-
- // LET MESSAGING DISPOSE unneededToken itself.
- THROW(errAEEventNotHandled);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallGetErrDescProc
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallGetErrDescProc(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODDesc** errDesc)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallGetErrDescProc");
-
- OSErr error = errAEEventNotHandled;// = CallGetErrDescProc(thePart, errDesc);
- SOM_TRY
- somSelf->CheckValid(ev);
- WARN( "DefaultAccessorSICallGetErrDescProc not implemented" );
- THROW_IF_ERROR(error);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallGetMarkTokenProc
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallGetMarkTokenProc(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODOSLToken* dContainerToken,
- ODDescType containerClass,
- ODOSLToken* result)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallGetMarkTokenProc");
-
- OSErr error = errAEEventNotHandled;// = CallGetMarkTokenProc(thePart, dContainerToken,
- // containerClass, result);
- SOM_TRY
- somSelf->CheckValid(ev);
- WARN( "DefaultAccessorSICallGetMarkTokenProc not implemented" );
- THROW_IF_ERROR(error);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallMarkProc
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallMarkProc(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODOSLToken* dToken,
- ODOSLToken* markToken,
- ODSLong index)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallMarkProc");
-
- OSErr error = errAEEventNotHandled;// = CallMarkProc(thePart, dToken, markToken, index);
- SOM_TRY
- somSelf->CheckValid(ev);
- WARN( "DefaultAccessorSICallMarkProc not implemented" );
- THROW_IF_ERROR(error);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DefaultAccessorSI::CallAdjustMarksProc
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK DefaultAccessorSICallAdjustMarksProc(DefaultAccessorSI *somSelf, Environment *ev,
- ODPart* thePart,
- ODSLong newStart,
- ODSLong newStop,
- ODOSLToken* markToken)
- {
- DefaultAccessorSIData *somThis = DefaultAccessorSIGetData(somSelf);
- DefaultAccessorSIMethodDebug("DefaultAccessorSI","DefaultAccessorSICallAdjustMarksProc");
-
- OSErr error = errAEEventNotHandled;// = CallAdjustMarksProc(thePart, newStart, newStop, markToken);
- SOM_TRY
- somSelf->CheckValid(ev);
- WARN( "DefaultAccessorSICallAdjustMarksProc not implemented" );
- THROW_IF_ERROR(error);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Utility functions
- //------------------------------------------------------------------------------
-
- static void ResolveDesc( Environment *ev, ODPart* part, ODSession* session,
- ODOSLToken* obj, AEDesc* data )
- {
- ODNameResolver* resolver = session->GetNameResolver(ev);
-
- if ( resolver->IsODToken( ev, obj ) )
- {
- AEDesc userToken, tmpDesc;
- AERecord fakeReply, fakeAEVT;
- userToken.dataHandle = tmpDesc.dataHandle = fakeReply.dataHandle =
- fakeAEVT.dataHandle = NULL;
- ODAppleEvent* odreply, *odaevt; ODVolatile(odaevt);
- odreply = odaevt = kODNULL; ODVolatile(odreply);
-
- TRY
- ODDesc* userTokenHolder = resolver->GetUserToken( ev, obj );
- THROW_IF_ERROR( ODDescToAEDesc( userTokenHolder, &userToken ) );
- if ( userToken.descriptorType == cProperty )
- {
- (void)AEDisposeDesc( &userToken );
-
- THROW_IF_ERROR( ODDescToAEDesc( obj, &tmpDesc ) );
- THROW_IF_ERROR( AECreateList( NULL, 0, true, &fakeAEVT ) );
- THROW_IF_ERROR( AEPutParamDesc( &fakeAEVT, keyDirectObject,
- &tmpDesc ) );
- (void)AEDisposeDesc( &tmpDesc );
- odaevt = new ODAppleEvent();
- THROW_IF_NULL(odaevt);
- odaevt->InitODAppleEvent( ev );
- THROW_IF_ERROR( AEDescToODDesc( &fakeAEVT, odaevt ));
- (void)AEDisposeDesc( &fakeAEVT );
-
- THROW_IF_ERROR( AECreateList( NULL, 0, true, &fakeReply ) );
- odreply = new ODAppleEvent();
- THROW_IF_NULL(odreply);
- odreply->InitODAppleEvent( ev );
- THROW_IF_ERROR( AEDescToODDesc( &fakeReply, odreply ));
- (void)AEDisposeDesc( &fakeReply );
-
- THROW_IF_ERROR( HandleGetData( ev, part, odaevt, odreply,
- session ) );
- ODDeleteObject( odaevt );
-
- THROW_IF_ERROR( ODDescToAEDesc( odreply, &fakeReply ));
- THROW_IF_ERROR( AEGetParamDesc( &fakeReply, keyDirectObject,
- typeWildCard, data ) );
- (void)AEDisposeDesc( &fakeReply );
- ODDeleteObject( odreply );
- }
- else
- {
- *data = userToken;
- }
- CATCH_ALL
- (void)AEDisposeDesc( &userToken );
- (void)AEDisposeDesc( &tmpDesc );
- (void)AEDisposeDesc( &fakeReply );
- (void)AEDisposeDesc( &fakeAEVT );
- ODDeleteObject( odaevt );
- ODDeleteObject( odreply );
- RERAISE;
- ENDTRY
- }
- else
- {
- THROW_IF_ERROR( ODDescToAEDesc( obj, data ) );
- }
- }
-
- static short BitwiseCompare( AEDesc* data1, AEDesc* data2 )
- {
- unsigned char* ptr1 = (unsigned char*)*(data1->dataHandle);
- unsigned char* ptr2 = (unsigned char*)*(data2->dataHandle);
- long len1 = GetHandleSize(data1->dataHandle);
- long len2 = GetHandleSize(data2->dataHandle);
-
- short result = 0;
- while ( len1 && len2 )
- {
- if ( *ptr1 == *ptr2 )
- {
- ++ptr1; ++ptr2;
- --len1; --len2;
- continue;
- }
- result = *ptr1 > *ptr2 ? 1 : -1;
- break;
- }
- // if we're here it's 'cause we ran off one end.
- if ( result == 0 )
- {
- if ( len1 )
- result = 1;
- else if ( len2 )
- result = -1;
- else
- result = 0;
- }
- return result;
- }
-
- static short CompareDescs( AEDesc* data1, AEDesc* data2 )
- {
- typedef long doubleLong[2];
- short result = 0;
- if ( data1->descriptorType != data2->descriptorType )
- {
- WARN( "CompareDescs: coercion should have been done already" );
- THROW( errAECoercionFail );
- }
- else
- switch( data1->descriptorType )
- {
- case typeChar:
- // <eeh> need to lowercase if possible. Really ought to
- // check out the considerations flags, but they're probably
- // not accessible.
- // $$$$$ not yet tested on Kanji system. For instance, double-byte
- // representations of Roman characters should be equal to their
- // single-byte equivalents. Are they using this code?
- HLock(data1->dataHandle);
- HLock(data2->dataHandle);
- long str1Len = GetHandleSize( data1->dataHandle );
- long str2Len = GetHandleSize( data2->dataHandle );
- UppercaseText( *data1->dataHandle, str1Len, smCurrentScript );
- UppercaseText( *data2->dataHandle, str2Len, smCurrentScript );
- result = CompareText( *data1->dataHandle, *data2->dataHandle,
- str1Len, str2Len, NULL );
- break;
- case typeLongInteger: // signed, so bitwise doesn't work!
- signed long l1 = *(signed long*)*(data1->dataHandle);
- signed long l2 = *(signed long*)*(data2->dataHandle);
- result = (l1 == l2)? 0 : l1 > l2? 1 : -1;
- break;
- case typeType:
- case typeEnumeration:
- case typeLongDateTime:
- case typeBoolean:
- default: // <eeh> should unknown types throw an error
- // instead?
- result = BitwiseCompare( data1, data2 );
- break;
- }
- return result;
- }
-
- #if 0
- // This isn't being used right now but probably will be later.
- void GetUserTokenFromDesc( Environment* ev, ODNameResolver* resolver,
- AEDesc* tokenWrapper, AEDesc* resultDesc )
- {
- ODOSLToken* odWrapper = new ODOSLToken();
- THROW_IF_NULL(odWrapper);
- odWrapper->InitODOSLToken(ev);
- THROW_IF_ERROR( AEDescToODDesc( tokenWrapper, odWrapper ) );
- WASSERT( resolver->IsODToken( ev, odWrapper ) );
- ODDesc* userTokenWrapper = resolver->GetUserToken( ev, odWrapper );
- THROW_IF_ERROR( ODDescToAEDesc( userTokenWrapper, resultDesc ) );
- ODDeleteObject( odWrapper );
- }
-
- static ODBoolean ContainerRepresentsPart( Environment* ev,
- ODNameResolver* resolver, ODOSLToken* container )
- {
- ODBoolean result = kODFalse;
- if ( resolver->IsODToken( ev, container ) )
- {
- ODDesc* tmpToken = resolver->GetUserToken(ev, container);
- ODDescType tokenType = tmpToken->GetDescType(ev);
- // (NULL token is not acceptable here)
- // <eeh> putting NULL back in because this breaks "every part whose"
- // when the root isn't scriptable.
- if ( (tokenType == kODStandardPartTokenType) || (tokenType == typeNull) )
- result = kODTrue;
- else if ( tokenType == typeAEList )
- THROW( kODErrUndefined );
- else
- {
- AEDesc token;
- THROW_IF_ERROR( ODDescToAEDesc( tmpToken, &token ) );
- if ( CanBeStandardPartToken( &token ) )
- result = kODTrue;
- (void)AEDisposeDesc( &token );
- }
- }
- return result;
- }
- #endif
-
-